#pragma once
#include "../mqcommon/Log.hpp"
#include "../mqcommon/Helper.hpp"
#include "../mqcommon/proto.pb.h"
#include <iostream>
#include <unordered_map>
#include <mutex>
#include <memory>
#include <vector>
#include <functional>
using namespace std;
namespace mq
{
    using openChannelRequestPtr = shared_ptr<mq::openChannelRequest>;
    using closeChannelRequestPtr = shared_ptr<mq::closeChannelRequest>;
    using declareExchangeRequestPtr = shared_ptr<mq::declareExchangeRequest>;
    using deleteExchangeRequestPtr = shared_ptr<mq::deleteExchangeRequest>;
    using declareQueueRequestPtr = shared_ptr<mq::declareQueueRequest>;
    using deleteQueueRequestPtr = shared_ptr<mq::deleteQueueRequest>;
    using BindRequestPtr = shared_ptr<mq::BindRequest>;
    using unBindRequestPtr = shared_ptr<mq::unBindRequest>;
    using basicPublishRequestPtr = shared_ptr<mq::basicPublishRequest>;
    using basicAckRequestPtr = shared_ptr<mq::basicAckRequest>;
    using basicConsumeRequestPtr = shared_ptr<mq::basicConsumeRequest>;
    using basicCancelRequestPtr = shared_ptr<mq::basicCancelRequest>;
    using basicConsumeResponsePtr = shared_ptr<mq::basicConsumeResponse>;
    using basicCommonResponsePtr = shared_ptr<mq::basicCommonResponse>;
    using ConsumerCallback = function<void(const string &, const mq::BasicProperties *, const string &)>;

    class Consumer
    {
    public:
        using ConsumerPtr = shared_ptr<Consumer>;
        Consumer()
        {
            DLOG("新建消费者: %p", this);
        }
        Consumer(const string &tag, const string &qname, bool auto_ack, ConsumerCallback cb)
            : _tag(tag), _qname(qname), _auto_ack(auto_ack), _callback(cb)
        {
            DLOG("新建消费者: %p", this);
        }
        ~Consumer()
        {
            DLOG("删除消费者: %p", this);
        }

    public:
        string _tag;    // 消费者标识
        string _qname;  // 消费者订阅的队列名称
        bool _auto_ack; // 自动确认标志
        ConsumerCallback _callback;
    };
}
